//
//  smuNodeReader.cpp
//  smu_test1
//
//  Created by jiayi on 16/9/25.
//
//

#include "smuCommon.hpp"
#include "smuNodeReader.h"

int smuNodeReader::loadResourceFile(const char *filename)
{
    ifstream in( filename );
    string line;
    
    if( in ) // exist
    {
        while ( getline( in, line ) )
        {
            _readerData.push_back( line );
        }
    }
    else // isn't exist
    {
        return smuError::no_txt;
    }
    return smuError::ok;
}

int smuNodeReader::saveResourceFile( const char* filename )
{
    ofstream out( filename );
    if( out ){
        smuReaderDataIter iter = _readerData.begin();
        for( ; iter != _readerData.end(); ++ iter ) {            
            out << (*iter) << "\n";
        }
    }else{
        return smuError::no_txt;
    }
    out.close();
    return smuError::ok;
}
